let ImportService = require('./ImportService')

class TestCaseService extends ImportService{
  initParam () {
    this.tableConfigs = [
      { tableName: 'users' }
    ]
  }

  formateData (dataList) {
    return new Promise((resolve, reject) => {
      let rowDatas = []
      let data = {}
      // 1.数据转换
      for (let i = 1, len = dataList.length; i < len; i++) {
        data = dataList[i]
        rowDatas.push({
          "zrbm": data[1],
          "djbh": data[2],
          "khmc": data[3],
          "khhtxm": data[4],
          "xmyfkzje": data[5],

          "xsht_bh": data[6],
          "xsht_zje": data[7],
          "xsht_qdsj": data[8],
          "xsht_hkzje": data[9],
          "xsht_hkbl": data[10],
          "xsht_yfwje": data[11],
          "xsht_yfwhkje": data[12],

          "xsht_dychkje": data[13],
          "xsht_dychksj": data[14],
          // "xsht_dychkbl": data[15],
          "xsht_dechkje": data[15],
          "xsht_dechksj": data[16],
          // "xsht_dechkbl": data[18],
          "xsht_dschkje": data[17],
          "xsht_dschksj": data[18],
          // "xsht_dschkbl": data[21],
          "xsht_dsichkje": data[19],
          "xsht_dsichksj": data[20],
          // "xsht_dsichkbl": data[24],
          "xsht_dwchkje": data[21],
          "xsht_dwchksj": data[22],
          // "xsht_dwchkbl": data[27],

          "wcht_gysmc": data[23],
          "wcht_htbh": data[24],
          "wcht_htzje": data[25],
          "wcht_htqdsj": data[26],
          "wcht_yfkzje": data[27],
          "wcht_yfkbl": data[28],

          "wcht_ycfkje": data[29],
          "wcht_ycsqsj": data[30],
          "wcht_ycfkbl": data[31],
          "wcht_ycfkdh": data[32],
          "wcht_ycfkdf": data[33] === '是' ? true : false,
          "wcht_ycdffwn": data[34] === '是' ? true : false,

          "wcht_ecfkje": data[35],
          "wcht_ecsqsj": data[36],
          "wcht_ecfkbl": data[37],
          "wcht_ecfkdh": data[38],
          "wcht_ecfkdf": data[39] === '是' ? true : false,
          "wcht_ecdffwn": data[40] === '是' ? true : false,

          "wcht_scfkje": data[41],
          "wcht_scsqsj": data[42],
          "wcht_scfkbl": data[43],
          "wcht_scfkdh": data[44],
          "wcht_scfkdf": data[45] === '是' ? true : false,
          "wcht_scdffwn": data[46] === '是' ? true : false,

          "wcht_sicfkje": data[47],
          "wcht_sicsqsj": data[48],
          "wcht_sicfkbl": data[49],
          "wcht_sicfkdh": data[50],
          "wcht_sicfkdf": data[51] === '是' ? true : false,
          "wcht_sicdffwn": data[52] === '是' ? true : false,

          "wcht_wcfkje": data[53],
          "wcht_wcsqsj": data[54],
          "wcht_wcfkbl": data[55],
          "wcht_wcfkdh": data[56],
          "wcht_wcfkdf": data[57] === '是' ? true : false,
          "wcht_wcdffwn": data[58] === '是' ? true : false,

          "ownerUser": this.dataFormater('users', data[59], 'email', 'userName'),
          "orgId": this.user.orgId[0],
          "createUser": this.user.email,
          "createDate": new Date(),
          "lastUpdateDate": new Date(),
          "lastUpdateUser": this.user.email,
          "updateHistory": [{
            'userId': this.user.email,
            'updateDate': new Date()
          }]
        })        
      }
      resolve(rowDatas)
    })
  }
}

module.exports = new TestCaseService()